//
//  MsgCellLayoutAdapterConfig.swift
//  swiftim
//
//  Created by yangjian on 2023/6/2.
//

import Foundation




class MsgCellLayoutAdapterConfig{
    static let share = MsgCellLayoutAdapterConfig()
    private init(){}

    let userInfoLayoutAdapter = MsgCellUserInfoLayoutAdapter(headTop: 4,headFromSide: 14,headWidth: 40 ,headHeight: 40 ,nameTop: 4,nameFromSide: 16,nameHeight: 14)
    let backgroundLayoutAdapter = MsgCellMsgBackgroundLayoutAdapter(top: 4,fromSide: 0,toSide: 60,bottom: 8)
    let contentLayoutAdapter = MsgCellMsgContentLayoutAdapter(top: 16,bottom: 16,fromSide: 30,toSide: 30)
    let contentUnknownLayoutAdapter = MsgCellMsgContentLayoutAdapter(top: 16,bottom: 16,fromSide: 30,toSide: 30)
    
    func msgBackgroundWidth() -> CGFloat{
        backgroundLayoutAdapter.msgBackgroundWidth(userInfoAdapter: self.userInfoLayoutAdapter)
    }
    
    
    func cellHeight_subtractMsgBackgroundHeight(showName : Bool) -> CGFloat{
        backgroundLayoutAdapter.cellHeight_subtractMsgBackgroundHeight(userInfoAdapter: self.userInfoLayoutAdapter, showName: showName)
    }

    func cellMinHeight() -> CGFloat{
        backgroundLayoutAdapter.cellMinHeight(userInfoAdapter: userInfoLayoutAdapter)
    }
    
    //cellHeight - contentHeight后 , 所剩高度
    func cellHeight_subtractMsgContentHeight(showName : Bool) -> CGFloat{
        contentLayoutAdapter.cellHeight_subtractMsgContentHeight(userInfoAdapter: userInfoLayoutAdapter, backgroundAdapter: backgroundLayoutAdapter, showName: showName)
    }
    
    func msgContentMaxWidth() -> CGFloat{
        contentLayoutAdapter.msgContentMaxWidth(userInfoAdapter: userInfoLayoutAdapter, backgroundAdapter: backgroundLayoutAdapter)
    }
    
    
    
    
    
}

let IM_CHAT_LAYOUT_DISPLAYSTYLE = "im_chat_layout_display_style"
class MsgCellBubbleLayoutAdapterConfig{
    
    static let share = MsgCellBubbleLayoutAdapterConfig()
    private init(){
        self.displayStyle = UserDefaults.standard.integer(forKey: IM_CHAT_LAYOUT_DISPLAYSTYLE)
        self.displayStyle = 1
    }

    var defaultAdapter =
    MsgCellBubbleLayoutAdapter(
        sendImageName: "bubble_send_default" ,
        receiveImageName: "bubble_receive_default",
        top : 13,
        bottom : 13,
        fromSide : 13,
        toSide : 13,
        resizableTop : 12,
        resizableBottom : 12,
        resizableFromSide : 12,
        resizableToSide : 12
    )
    
    let catAdapter =
    MsgCellBubbleLayoutAdapter(
        sendImageName: "bubble_cat_send" ,
        receiveImageName: "bubble_cat_receive",
        top : 16,
        bottom : 13,
        fromSide : 20,
        toSide : 16,
        resizableTop : 16,
        resizableBottom : 13,
        resizableFromSide : 23,
        resizableToSide : 28
    )

    var displayStyle = 1
    
    func currentAdapter() -> MsgCellBubbleLayoutAdapter{
        if displayStyle == 1 {
            return catAdapter
        } else {
            return defaultAdapter
        }
    }
}


class MsgCellOtherLayoutAdapterConfig {
    static let share = MsgCellOtherLayoutAdapterConfig()
    private init(){}

    var timeMarkerCellHeight : CGFloat = 36
    
    var systemRemindTopAndBottomEdgeSpacing : CGFloat = 12
    var systemRemindLeftAndRightMiniEdgeSpacing : CGFloat = 20
    
    var bigEmojiContentSize : CGSize = CGSize(width: 80, height: 80)
    
    var locationCellMsgContentWidth : CGFloat = MsgCellLayoutAdapterConfig.share.msgContentMaxWidth()
    var locationCellTextLeftAndRightSide : CGFloat = 6
    var businessCardCellContentHeight : CGFloat = 140
    
    var voiceContentViewHeight : CGFloat = 24
//    var voiceContentTextContentSpacing : CGFloat = 12
    var voiceConvertTextEdgeSpacing : CGFloat = 8
    var voiceConvertTextToBottom : CGFloat = 4

}
